<template>
  <!-- 设置估价批量修改 -->
  <el-dialog title="信息" :visible.sync="openGuaranteeValuationPatchUpdate" width="800px" append-to-body :destroy-on-close="true" :before-close="beforeClose">
    <el-form ref="form" label-width="80px" :inline="true">
      <el-form-item label="货物估价(元/吨)" prop="jine">
        <el-input
          v-model="jine"
          placeholder="货物估价(元/吨)"
          clearable
        />
      </el-form-item>
      <el-form-item label="备注" prop="itbz">
        <el-input
          v-model="itbz"
           clearable
        />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="isPatchUpdate" v-hasPermi="['zhcloud:hwdb:modify']">批量修改</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { valuationRevision } from "@/api/storage/guarantee";

export default {
  name: "UpdatePatchPrice",
  data() {
    return {
      //弹窗状态
      openGuaranteeValuationPatchUpdate: false,
      jine:"",
      itbz:"",
      // 查询参数
      queryParams: [],
    };
  },
  methods: {
    /**关闭弹窗 */
    beforeClose(done) {
      this.changeGuaranteeValuationPatchUpdate()
      this.resetQuery()
      this.$emit('refresh', true)
      done()
    },

    /** 重置按钮操作 */
    resetQuery() {
      this.jine = ""
      this.itbz = ""
    },

    /**改变窗口状态 */
    changeGuaranteeValuationPatchUpdate() {
      this.openGuaranteeValuationPatchUpdate = !this.openGuaranteeValuationPatchUpdate;
    },

    /**打开弹窗 */
    open(data) {
      this.changeGuaranteeValuationPatchUpdate()
      this.queryParams = data
    },
    patchUpdate() { 
      valuationRevision(this.queryParams).then(response => {
        this.changeGuaranteeValuationPatchUpdate()
        this.$modal.msgSuccess("执行成功");  
      });
    },
     
    isPatchUpdate() {
      this.$modal.confirm('是否进行批量修改？').then(() => {
        const queryParams = this.queryParams
        for(let i in queryParams) {
          queryParams[i].jine = this.jine
          queryParams[i].itbz = this.itbz
        }
        this.patchUpdate();
      }).catch(() => {});
      
    }
  }
};
</script>
